package com.bootdo.clouddo.service.douban.impl;

import com.bootdo.clouddo.dao.douban.DbBookRatingMapper;
import com.bootdo.clouddo.domain.douban.DbBookRating;
import com.bootdo.clouddo.service.douban.IDbBookRatingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DbBookRatingServiceImpl implements IDbBookRatingService {

    @Autowired
    private DbBookRatingMapper dao;

    @Override
    public DbBookRating findById(Long id) {
        return dao.selectByPrimaryKey(id);
    }

    @Override
    public int save(DbBookRating record) {
        if(findById(record.getId()) != null)
            return dao.updateByPrimaryKeySelective(record);
        else
            return dao.insertSelective(record);
    }

    @Override
    public List<Long> findNoRatingIds() {
        return dao.findNoRatingIds();
    }
}
